package com.elephant.core.mianshi;

public class Resource implements AutoCloseable, Runnable {

    static {
        System.out.println("static code");
    }

    public Resource(){
        System.out.println("struct init");
    }

    @Override
    public void run() {
        System.out.println("run method");
        throw new RuntimeException("");
    }

    public static void main(String[] args) {
        try(Resource resource = new Resource()) {
            System.out.println("=====start====");
            resource.run();
        }catch (Exception e){
            System.out.println("exception");
        }finally {
            System.out.println("finally");
        }
    }

    @Override
    public void close() {
        System.out.println("close");
    }
}
